package com.systop.ltbook.book.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

import com.systop.core.model.BaseModel;
import com.systop.ltbook.book.press.model.Press;
import com.systop.ltbook.book.subject.model.Subject;
import com.systop.ltbook.favorite.model.Favorite;

/**
 * 图书类
 * 
 * @author Lunch
 */

@Entity
@Table(name = "books")
@SuppressWarnings("serial")
public class Book extends BaseModel {

	/** 主键 */
	private Integer id;

	/** 书名 */
	private String name;

	/** 作者 */
	private String author;

	/** 图书类型 */
	private String bkType;

	/** 学科 */
	private Subject subject;

	/** 年级 */
	private String grade;

	/** 描述 */
	private String descn;

	/** 出版社 */
	private Press press;

	/** 出版日期 */
	private Date pubDate;

	/** 版次 */
	private String version;

	/** 页数 */
	private String pageCount;

	/** 字数 */
	private String wordCount;

	/** 印刷日期 */
	private Date printDate;

	/** 开本 */
	private String bookSize;

	/** 纸张描述 */
	private String paperDesc;

	/** 印刷次数 */
	private String printCount;

	/** ISBN图书编号吧 */
	private String isbn;

	/** 包装描述 */
	private String packDescn;

	/** 单价[应该是不直接显示，而是需要下级客户咨询] */
	private Double price;

	/** 库存 */
	private Integer stock;

	/** 封面照片 */
	private String coverPhoto;

	/** 收藏次数 */
	private Integer favoriteCount;

	/** 排序号 */
	private Integer orderNum;
	
	//创建时间
	private Date updateTime;
	
	//至顶
	private String onTop;

	private Set<Favorite> favorites = new HashSet<Favorite>();

	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "ID", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "subject")
	public Subject getSubject() {
		return subject;
	}

	public void setSubject(Subject subject) {
		this.subject = subject;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	@Column(name = "descn")
	@Type(type = "text")
	public String getDescn() {
		return descn;
	}

	public void setDescn(String descn) {
		this.descn = descn;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "press")
	public Press getPress() {
		return press;
	}

	public void setPress(Press press) {
		this.press = press;
	}

	public Date getPubDate() {
		return pubDate;
	}

	public void setPubDate(Date pubDate) {
		this.pubDate = pubDate;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getPageCount() {
		return pageCount;
	}

	public void setPageCount(String pageCount) {
		this.pageCount = pageCount;
	}

	public String getWordCount() {
		return wordCount;
	}

	public void setWordCount(String wordCount) {
		this.wordCount = wordCount;
	}

	public Date getPrintDate() {
		return printDate;
	}

	public void setPrintDate(Date printDate) {
		this.printDate = printDate;
	}

	public String getBookSize() {
		return bookSize;
	}

	public void setBookSize(String bookSize) {
		this.bookSize = bookSize;
	}

	public String getPaperDesc() {
		return paperDesc;
	}

	public void setPaperDesc(String paperDesc) {
		this.paperDesc = paperDesc;
	}

	public String getPrintCount() {
		return printCount;
	}

	public void setPrintCount(String printCount) {
		this.printCount = printCount;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

	public String getPackDescn() {
		return packDescn;
	}

	public void setPackDescn(String packDescn) {
		this.packDescn = packDescn;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Integer getStock() {
		return stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	public String getCoverPhoto() {
		return coverPhoto;
	}

	public void setCoverPhoto(String coverPhoto) {
		this.coverPhoto = coverPhoto;
	}

	public Integer getFavoriteCount() {
		return favoriteCount;
	}

	public void setFavoriteCount(Integer favoriteCount) {
		this.favoriteCount = favoriteCount;
	}

	public Integer getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

	public String getBkType() {
		return bkType;
	}

	public void setBkType(String bkType) {
		this.bkType = bkType;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "book")
	public Set<Favorite> getFavorites() {
		return favorites;
	}

	public void setFavorites(Set<Favorite> favorites) {
		this.favorites = favorites;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}
	
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	

	@Column(name="on_top", length = 1)
	public String getOnTop() {
		return onTop;
	}


	public void setOnTop(String onTop) {
		this.onTop = onTop;
	}
	
}
